<?php

namespace backend\controllers;
use yii;
use yii\web\Controller;
use backend\models\service\Order;
use backend\behaviors\OrderBehavior;
use yii\filters\AccessControl;

class OrderController extends Controller
{
    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
            'access' => [
                'class' => AccessControl::className(),
                'rules' => [
                    [
                        'allow' => true,
                        'roles' => ['@'],
                    ],
//                    [
//                        'actions' => ['login', 'captcha'],
//                        'allow' => true,
//                        'roles' => ['?'],
//                    ],
                ],
            ],
        ];
    }
    public function actionIndex()
    {
        $model = new Order();
        $model->attachBehavior('order', new OrderBehavior);
        $model->load(Yii::$app->request->queryParams);
        //全部分类
        $category = \backend\models\novel\NovelCategory::getAllCategory();
        return $this->render('index', [
            'dataProvider' => $model->list_for_index(),
            'category' => $category,
            'select' => Yii::$app->request->queryParams, 
        ]);
    }

}
